#region Copyright RenGuiYou. All rights reserved.

//=====================================================
// PandoraFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================

#endregion

using UnityEngine.Profiling;
using UnityEngine;

namespace Pandora.Console
{
    public class ProfilerInfoWindow : ScrollWindowBase
    {
        private const float KBSize = 1024;
        private const float MBSize = 1024 * KBSize;

        protected override void OnDrawScrollableWindow()
        {
            GUILayout.Label("<b>Unity Profiler</b>");
            GUILayout.BeginVertical("box");
            {
                DrawItem("Mono自身内存:", string.Format("{0:F3} MB", (Profiler.GetMonoUsedSizeLong() / MBSize)));
                DrawItem("Mono使用内存:", string.Format("{0:F3} MB", (Profiler.GetMonoHeapSizeLong() / MBSize)));
                DrawItem("堆内存使用:", string.Format("{0:F3} MB", (Profiler.usedHeapSizeLong / MBSize)));
                DrawItem("总内存分配:", string.Format("{0:F3} MB", (Profiler.GetTotalAllocatedMemoryLong() / MBSize)));
                DrawItem("总预留内存:", string.Format("{0:F3} MB", (Profiler.GetTotalReservedMemoryLong() / MBSize)));
                DrawItem("未使用内存:", string.Format("{0:F3} MB", (Profiler.GetTotalUnusedReservedMemoryLong() / MBSize)));
            }
            GUILayout.EndVertical();
            GUILayout.Label("<b>Lua Profiler</b>");
            GUILayout.BeginVertical("box");
            {
                DrawItem("Lua内存:", string.Format("{0:F3} MB", (PdrConsoleWindow.luaMemorySize / KBSize)));
                DrawItem("Lua内存(单位秒):", string.Format("{0} KB", PdrConsoleWindow.luaMemoryDelta));
            }
            GUILayout.EndVertical();
        }
    }
}